<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@page import="com.juitar.base.utils.*,com.juitar.base.*,java.util.*"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@page import="chord.finder.HtmlHelper"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="style.css" />
<title><c:out value="${chordName}" default="" /></title>
</head>
<body>

<div class="search.form">
<table class="center" align="center" height="100%">
	<tr>
		<td>
		<form class="center" name="chord-params" action="controller"
			method="get">Chord <select name="root">
			<c:forEach var="note" items="${notes}">
				<c:set var="selected" value="" />
				<c:if test="${param.root == note.intValue}">
					<c:set var="selected" value="selected" />
				</c:if>
				<option value="${note.intValue}"${selected}>${note}</option>
			</c:forEach>
		</select> <select name="chord">
			<c:forEach var="chord" items="${chords}" varStatus="status">
				<c:set var="selected" value="" />
				<c:if test="${param.chord == status.index}">
					<c:set var="selected" value="selected" />
				</c:if>
				<option value="${status.index}"${selected}>${chord.name}</option>
			</c:forEach>
		</select> <input type="submit"></form>
		</td>
	</tr>
</table>
</div>

<!-- 
  <c:forEach var="fing" items="${fingerings}">
  	<c:set var="firstFret" value="-1" />
	<h3>Chord ${chordName}</h3>
  	<c:if test="${fing.firstFret != firstFret}">
  		<c:if test="${firstFret != -1}">
	  		<c:out value="</div>"></c:out> 	
  		</c:if>
  		<c:set var="firstFret" value="${fing.firstFret}"/>
  		<h3>Chords at ${firstFret} position</h3>
  	</c:if>	
  </c:forEach>
 -->
 
<div class="fingerings">
<%
     Collection<Fingering> fingerings = (Collection<Fingering>) request
             .getAttribute("fingerings");
     if (fingerings != null) {
         out.println("<h3>Chord " + request.getAttribute("chordName") + " </h3>");
         int firstFret = -1;
         for (Fingering fing : fingerings) {
             if (fing.getFirstFret() != firstFret) {
                 if (firstFret != -1) {
                     out.println("</div>");
                 }
                 firstFret = fing.getFirstFret();
                 out.println("<h3>Chords at " + firstFret + " position</h3>");
                 out.println("<div>");
             }
             String table = HtmlHelper.toHtmlTable(fing);
             out.println(table);
             out.println("&nbsp;&nbsp;&nbsp;&nbsp;");
         }
         out.println("</div>");
     }
 %>
</div>
</body>
</html>